package com.example.apollotogit.utils;

import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;

import java.nio.charset.StandardCharsets;
import java.util.Properties;

/**
 * 邮件客户端
 */
public class MailClient {
    /**
     * 初始化发送信息
     * @return 发送对象
     */
    private JavaMailSender createJavaMailSender() {
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
        mailSender.setDefaultEncoding(StandardCharsets.UTF_8.name());
        String username = "yunwei@dejax.com";
        //设置用户名
        mailSender.setUsername(username);
        //设置授权码
        mailSender.setPassword("yw18@abcd");
        Properties props = new Properties();
        //设置邮件服务器地址
        props.put("mail.smtp.host", "smtp.163.com");
        //开启认证
        props.put("mail.smtp.auth", "true");
        mailSender.setJavaMailProperties(props);
        return mailSender;
    }
}
